package com.wl.common;

import java.io.File;

import static com.wl.common.FileUtil.getFileExtension;
import static com.wl.common.WindowComponent.showAlert;
import static com.wl.convert.PdfToDocxConverter.convertPdfToDoc;
import static com.wl.convert.PdfToDocxConverter.convertPdfToDocx;
import static com.wl.convert.PdfToOfdConverter.convertPdfToOfd;

// 转换主函数，用来判断分发转换文档
public class ConverterDocMain {
  public static void converterMain(String converterDocType, File thisFile) {
    String fileExtension = getFileExtension(thisFile);

    switch (fileExtension) {
      case "pdf":
        if ("docx".equals(converterDocType)) {
          System.out.println("当前的类型为：" + converterDocType);
          System.out.println("即将要转换的类型：" + fileExtension);
          convertPdfToDocx(thisFile);
        } else if("doc".equals(converterDocType)){
          System.out.println("当前的类型为：" + converterDocType);
          System.out.println("即将要转换的类型：" + fileExtension);
          convertPdfToDoc(thisFile);
        } else if("ofd".equals(converterDocType)){
          System.out.println("当前的类型为：" + converterDocType);
          System.out.println("即将要转换的类型：" + fileExtension);
          convertPdfToOfd(thisFile);
        }
        break;
      default:
        showAlert("警告！⚠️", "无法转换当前类型文件。", "目前只支持pdf转换docx");
        System.out.println("无法解析当前格式为：" + fileExtension);

    }
  }
}
